package com.google.code.jskills;

import javax.enterprise.inject.spi.BeanManager;
import javax.naming.InitialContext;
import javax.naming.NamingException;

import org.apache.wicket.Page;
import org.apache.wicket.cdi.CdiConfiguration;
import org.apache.wicket.cdi.ConversationPropagation;
import org.apache.wicket.protocol.http.WebApplication;

import com.google.code.jskills.pages.Index;

public class MainApplication extends WebApplication {
	
	@Override
	public Class<? extends Page> getHomePage() {
		return Index.class;
	}

	@Override
	protected void init() {
		super.init();

		// Enable CDI
		BeanManager bm;
		try {
			bm = (BeanManager) new InitialContext().lookup("java:comp/BeanManager");
		} catch (NamingException e) {
			throw new IllegalStateException("Unable to obtain CDI BeanManager", e);
		}
		
		// Configure CDI, disabling Conversations as we aren't using them
		new CdiConfiguration(bm).setPropagation(ConversationPropagation.NONE).configure(this);

		// Mount the InsertContact page at /insert
		// mountPage("/insert", InsertContact.class);
	}

}
